package com.rjkj.medicalwaste;

import android.content.Context;
import android.util.Log;

import androidx.annotation.Keep;

import com.taobao.sophix.PatchStatus;
import com.taobao.sophix.SophixApplication;
import com.taobao.sophix.SophixEntry;
import com.taobao.sophix.SophixManager;
import com.taobao.sophix.listener.PatchLoadStatusListener;
/**
 * Sophix入口类，专门用于初始化Sophix，不应包含任何业务逻辑。
 * 此类必须继承自SophixApplication，onCreate方法不需要实现。
 * 此类不应与项目中的其他类有任何互相调用的逻辑，必须完全做到隔离。
 * AndroidManifest中设置application为此类，而SophixEntry中设为原先Application类。
 * 注意原先Application里不需要再重复初始化Sophix，并且需要避免混淆原先Application类。
 * 如有其它自定义改造，请咨询官方后妥善处理。
 */
public class SophixStubApplication extends SophixApplication {
    private final String TAG = "SophixStubApplication";
    // 此处SophixEntry应指定真正的Application，并且保证RealApplicationStub类名不被混淆。
    @Keep
    @SophixEntry(MWApplication.class)
    static class RealApplicationStub {}
    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
//         如果需要使用MultiDex，需要在此处调用。
//         MultiDex.install(this);
        initSophix();
    }
    private void initSophix() {
        String appVersion = "0.0.0";
        try {
            appVersion = this.getPackageManager()
                    .getPackageInfo(this.getPackageName(), 0)
                    .versionName;
        } catch (Exception e) {
        }
        final SophixManager instance = SophixManager.getInstance();
        instance.setContext(this)
                .setAppVersion(appVersion)
                .setSecretMetaData("333516395", "0f25ca1f8ec44c3082c0a6392b2fc412", "MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCj+5EFVtD2eHAV5CEXWCfo7HGIty4bc9yFJS5De7fV0fRkxjOnW2NvKkAfkoijT0s4FujpzVS72nl29UTDz9DC9hDD/rYsHTTWjZzUf/Bh4Wyf1E6gniz4B8ROYCQWK+cOHYUORkSh5DmZAFsjNa2EX28ytjKeerrm2CtWCDXUYCmoTqc85upJBW3tiCSxPdlJGiKR/Ke6WyxPNXTUeaUtYZumY6TVpkcMteAp42rBLsdZMZqCbdv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+ohGClbd2IfKTXaEshJwbRP4ZHDHTJGyAE0HjXf/ZCn0DWWv5YgPMtS0XugsQ7lbjkmkCgYBClSQQp39VHZ1dg+kUIOklCLjYoCPvkabN0sRO9VBvpN6LOOeiax2KVk39rSk8qquyc+3l46Z8T5G1RGpsdWOQorn5LE1jCHZdlYP1BY/ImB+ndqc8d0YwWAJze/lgqq0NG6bZex4iz6NdhYx/uQ0GPn3OFwn1iim9hj+/sBsu5Q==")
                .setEnableDebug(true)
                .setEnableFullLog()
                .setPatchLoadStatusStub(new PatchLoadStatusListener() {
                    @Override
                    public void onLoad(final int mode, final int code, final String info, final int handlePatchVersion) {
                        if (code == PatchStatus.CODE_LOAD_SUCCESS) {
                            Log.i(TAG, "sophix load patch success!");
                        } else if (code == PatchStatus.CODE_LOAD_RELAUNCH) {
                            // 如果需要在后台重启，建议此处用SharePreference保存状态。
                            Log.i(TAG, "sophix preload patch success. restart app to make effect.");
                        }
                    }
                }).initialize();
    }
}